<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${daoUrl}.${entityName}Dao">

	<resultMap id="BaseResultMap" type="${entityUrl}.${entityName}">
        <#list cis as ci>
            <id column="${ci.column}"  property="${ci.property}" />
        </#list>
	</resultMap>
	<sql id="Base_Column_List">
		${agile}
	</sql>

	<insert id="insert" keyColumn="id" keyProperty="id" parameterType="${entityUrl}.${entityName}" useGeneratedKeys="true">
		insert into ${table}
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <#list cis as ci>
                ${ci.column},
            </#list>
        </trim>
        <trim prefix=" values (" suffix=")" suffixOverrides=",">
            <#list cis as ci>
                ${SYSJINHAO}{${ci.property}},
            </#list>
        </trim>
	</insert>
	<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="${entityUrl}.${entityName}" useGeneratedKeys="true">
		insert into ${table}
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <#list cis as ci>
                <if test="${ci.property} != null">
                    ${ci.column},
                </if>
            </#list>
        </trim>
        <trim prefix=" values (" suffix=")" suffixOverrides=",">
            <#list cis as ci>
                <if test="${ci.property} != null">
                    ${SYSJINHAO}{${ci.property}},
                </if>
            </#list>
        </trim>
	</insert>

    <update id="delete${entityName}ByType">
        update ${table} set delete_type = ${SYSJINHAO}{deleteType}
        where id in
        <foreach
                collection="idList"
                item="id"
                open="("
                close=")"
                separator=",">${SYSJINHAO}{id,jdbcType=BIGINT}
        </foreach>
    </update>

    <delete id="delete${entityName}Record" parameterType="java.lang.Long">
        delete from  ${table}
        where id in
        <foreach
                collection="idList"
                item="id"
                open="("
                close=")"
                separator=",">${SYSJINHAO}{id,jdbcType=BIGINT}
        </foreach>
    </delete>

    <update id="updateByPrimaryKeySelective" parameterType="${entityUrl}.${entityName}">
        update ${table}
        <set>
            <trim  suffixOverrides=",">
                <#list cisNoId as ci>
                    <if test="${ci.property} != null">
                        ${ci.column} = ${SYSJINHAO}{${ci.property}},
                    </if>
                </#list>
            </trim>
        </set>
        where id = ${SYSJINHAO}{id,jdbcType=BIGINT}
    </update>

    <update id="updateByPrimaryKey" parameterType="${entityUrl}.${entityName}">
        update ${table}
        <set>
            <trim   suffixOverrides=",">
                <#list cisNoId as ci>
                    ${ci.column} = ${SYSJINHAO}{${ci.property}},
                </#list>
            </trim>
        </set>
        where id = ${SYSJINHAO}{id,jdbcType=BIGINT}
    </update>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from ${table}
        where id = ${SYSJINHAO}{id,jdbcType=BIGINT}
    </select>

    <select id="selectByPrimaryKeySelective"  resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from ${table}
        where 1=1
        <trim  suffixOverrides=",">
            <#list cisNoId as ci>
                <if test="record.${ci.property} != null">
                   and  ${ci.column} = ${SYSJINHAO}{record.${ci.property}}
                </if>
            </#list>
        </trim>
    </select>


</mapper>